home *** CD-ROM | disk | FTP | other *** search
- { Look Chn/Eng Text/1024x768,256 Colors }
-
- uses Dos,SVGA256,Txt;
-
- var Texts:array[0..15000] of ^string;
- LineMax:integer;
- DirInfo:SearchRec;
- Dir:DirStr; Name:NameStr; Ext:ExtStr;
- Font,FontAsc,FontSpc,FontSup:pointer;
- FileChn:string; { 12288,29376,26280 bytes }
-
- { ─────────────── InitChinese ─────────────── }
- procedure InitChinese(Chn,Asc,Spc,Sup:string);
- begin
- if (FileLen(Asc,1)<0) then
- begin Writeln; Writeln(''''+Asc+''' not found !'); Halt(1); end;
- if (FileLen(Spc,1)<0) then
- begin Writeln; Writeln(''''+Spc+''' not found !'); Halt(1); end;
- if (FileLen(Sup,1)<0) then
- begin Writeln; Writeln(''''+Sup+''' not found !'); Halt(1); end;
- FileChn:=Chn;
- GetMem(FontAsc,12288); FileRead(Asc,0,256,48,FontAsc^);
- GetMem(FontSpc,29376); FileRead(Spc,0,408,72,FontSpc^);
- GetMem(FontSup,26280); FileRead(Sup,0,365,72,FontSup^);
- end;
- { ─────────────── PrintC ─────────────── }
- procedure PrintC(Ty,X,Y,Color,BkColor,Space,Count:integer;St:string);
- var Buf1,Buf2:array[0..575] of byte; { Ty: 0=Mono, 1..4=Color }
- S1,O1,S2,O2,S3,O3,I,Hi,Lo,N,L,P:integer;
- C:word;
- File1:file;
- begin
- S1:=Seg(FontAsc^); O1:=Ofs(FontSpc^);
- S2:=Seg(FontSpc^); O2:=Ofs(FontSpc^);
- S3:=Seg(FontSup^); O3:=Ofs(FontSup^);
- Assign(File1,FileChn); Reset(File1,72);
- L:=Length(St); P:=0;
- while P<L do begin
- Hi:=Ord(St[P+1]); Lo:=Ord(St[P+2]); C:=Hi shl 8+Lo;
- case C of
- $A440..$C67E,$C940..$F9FE:begin
- if Lo>$7E then Dec(Lo,34);
- N:=157*(Hi-$A4)+Lo-$40; if N>5400 then Dec(N,408);
- if N<13094 then begin Seek(File1,N); BlockRead(File1,Buf1,1); end
- else Move(Mem[S2:O2+6192],Buf1,72);
- Conv1to8(Buf1,Buf2,72,Color,BkColor);
- Hi:=24; Lo:=24+Space; N:=2;
- end;
- $A140..$A3BF:begin
- if Lo>$7E then Dec(Lo,34);
- N:=157*(Hi-$A1)+Lo-$40;
- Conv1to8(Mem[S2:O2+72*N],Buf2,72,Color,BkColor);
- Hi:=24; Lo:=24+Space; N:=2;
- end;
- $C6A1..$C8FE:begin
- N:=157*(Hi-$C6)+Lo-$A1;
- Conv1to8(Mem[S3:O3+72*N],Buf2,72,Color,BkColor);
- Hi:=24; Lo:=24+Space; N:=2;
- end else begin
- Conv1to8(Mem[S1:O1+48*Hi],Buf2,48,Color,BkColor);
- Hi:=16; Lo:=12+Space shr 1; N:=1;
- end;
- end;
- if Ty>0 then Colorize(Ty,Hi,24,Color,Count,Color,Buf2);
- Put(X,Y,Hi,24,Buf2);
- Inc(X,Lo); Inc(P,N);
- end;
- Close(File1);
- end;
- { ─────────────── ReadTextFile ─────────────── }
- procedure ReadTextFile(Filename:string);
- var File1:text;
- St:string;
- I:integer;
- begin
- Assign(File1,Filename); Reset(File1);
- LineMax:=0;
- while not Eof(File1) do begin
- if (LineMax>15000) or (MemAvail<256) then begin Close(File1); Exit; end;
- Readln(File1,St);
- for I:=1 to 255 do if St[I]=#9 then
- begin Delete(St,I,1); Insert(' ',St,I); end;
- GetMem(Texts[LineMax],Length(St)+1);
- Texts[LineMax]^:=St;
- Inc(LineMax);
- end;
- Close(File1);
- end;
- { ─────────────── ShowPage ─────────────── }
- procedure ShowPage(X,Y:integer);
- var N,I,J:integer;
- St:string[80];
- begin
- if LineMax>23 then J:=23 else J:=LineMax;
- for I:=0 to J-1 do begin
- N:=Length(Texts[Y+I]^)-X;
- if N<0 then N:=0; if N>80 then N:=80;
- St[0]:=Chr(N); Move(Texts[Y+I]^[X+1],St[1],N);
- PrintC(0,32,42+30*I,64+I shr 1,104,0,2,St);
- Bar(32+12*N,42+30*I,12*(80-N),24,104);
- end;
- end;
- { ─────────────── Look ─────────────── }
- procedure Look;
- var X,Y,K:integer;
- St:string[5];
- begin
- FSplit(ParamStr(1),Dir,Name,Ext);
- ReadTextFile(Dir+DirInfo.Name);
- Bar(0,0,1024,30,54); Bar(0,30,1024,708,104); Bar(0,738,1024,30,54);
- PrintC(1,32, 3,63,54,0,2,'LookC V1.1 ññ¡^ñσÑ╗ñσ╛\┼¬╡{ªí (C) 1994 '+
- 'Jou-Nan Chen');
- PrintC(1,32,741,63,54,0,2,'í⌠í⌡-ñWñUªµ í≈í÷-ѬÑkñGñQªr '+
- 'PgUp,PgDn-ñWñU¡╢ Home,End-│╠½e,│╠½ß¡╢');
- X:=0; Y:=0; K:=0;
- repeat
- Bar(808,3,200,24,54);
- Str(X+1,St); PrintC(1,808,3,80,54,0,2,St);
- Str(Y+1,St); PrintC(1,880,3,80,54,0,2,St);
- if (K<>$2166) and (K<>$2146) then ShowPage(X,Y);
- K:=Key;
- case K of
- $4800:Dec(Y); $5000:Inc(Y); { Up,Down }
- $4900:Dec(Y,23); $5100:Inc(Y,23); { PgUp,PgDn }
- $4B00:Dec(X,20); $4D00:Inc(X,20); { Left,Right }
- $4700:begin X:=0; Y:=0; end; { Home }
- $4F00:begin X:=0; Y:=LineMax-23; end; { End }
- end;
- if Y>=LineMax-23 then Y:=LineMax-23; if Y<0 then Y:=0;
- if X>236 then X:=236; if X<0 then X:=0;
- until K=$011B; { Esc }
- end;
-
- begin
- if ParamCount=0 then
- begin Writeln('Usage: Look Filename'); Halt(1); end;
- if ParamCount=1 then begin
- FindFirst(ParamStr(1),Archive,DirInfo);
- if DosError<>0 then
- begin Writeln('No such file !'); Halt(1); end;
- end;
- InitChinese('\et3\stdfont.24','\et3\ascfont.24','\et3\spcfont.24',
- '\et3\spcfsupp.24');
- if TestVESA=0 then
- begin Writeln; Writeln('VESA driver not installed !'); Halt(1); end;
- SetMode(5); Look; SetMode(0);
- end.
-